//
//  YXSoreTypeViewController.m
//  CaoShi
//
//  Created by 杨旭 on 2018/10/15.
//  Copyright © 2018年 杨旭. All rights reserved.
//

#import "YXSoreTypeViewController.h"
#import "YXSorePublicCell.h"
#import <SDCycleScrollView.h>
#import "YXSoreDetailsViewController.h"
@interface YXSoreTypeViewController ()<UITableViewDelegate,UITableViewDataSource,SDCycleScrollViewDelegate>
@property (nonatomic ,strong) UITableView *tableView;
@property (nonatomic ,strong) SDCycleScrollView *cycleScrollView;
@property (nonatomic ,strong) NSArray *bannerArr;

@end

@implementation YXSoreTypeViewController

- (NSArray *)bannerArr {
    if (!_bannerArr) {
        _bannerArr = @[@"jiazheng_img",@"jiazheng_img",@"jiazheng_img"];
    }
    return _bannerArr;
}


- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:(CGRectMake(0, ISiPhoneX?88:64, kScreenWidth, kScreenHeight-(ISiPhoneX?88:64))) style:(UITableViewStylePlain)];
        _tableView.backgroundColor = color_backColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
        
        UIView *headerView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, kScreenWidth, 150))];
        headerView.backgroundColor = [UIColor py_colorWithHexString:@"#f2f2f2"];
        self.tableView.tableHeaderView = headerView;
        
    
        _cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:(CGRectMake(0, 0, kScreenWidth, 150)) delegate:self placeholderImage:[UIImage imageNamed:@""]];
        _cycleScrollView.localizationImageNamesGroup = self.bannerArr;
        [headerView addSubview:self.cycleScrollView];
        
        [_tableView registerNib:[UINib nibWithNibName:@"YXSorePublicCell" bundle:nil] forCellReuseIdentifier:@"YXSorePublicCell"];
    }
    return _tableView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"家政";
    
    [self.view addSubview:self.tableView];
}


#pragma mark - UITableView Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 90;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YXSorePublicCell *cell = [tableView dequeueReusableCellWithIdentifier:@"YXSorePublicCell" forIndexPath:indexPath];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    YXSoreDetailsViewController *vc = [[YXSoreDetailsViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
